const Koa = require('koa')
const query = require('./dbConfig/index')
const path = require('path')
const fs = require('fs')
const app = new Koa()
async function handelDb(){
	await query(`ALTER TABLE student ADD COLUMN uuid VARCHAR(36)`)
	await query(`UPDATE student SET uuid = UUID();`)
	await query(`ALTER TABLE student MODIFY uuid VARCHAR(36) UNIQUE`)
	const data = await query(`select uuid,student_name from student`)
	console.log(data)
	for(let i=0;i<data.length;i++){
		const filePath = path.join(__dirname, `./sudentTaskFile/${data[i].uuid}${data[i].student_name}.txt`);
		fs.writeFileSync(filePath, '', 'utf8');
	}
}
handelDb()

app.listen(3001,()=>console.log("服务已启动,端口号3001"))